package com.yuanfeng.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanfeng.commoms.exception.BizCodeEnume;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.goods.entity.GoodsCommonAttributeAssociationEntity;
import com.yuanfeng.goods.mapper.GoodsCommonAttributeAssociationMapper;
import com.yuanfeng.goods.service.GoodsCommonAttributeAssociationService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 *
 */
@Service
public class GoodsCommonAttributeAssociationImpl extends ServiceImpl<GoodsCommonAttributeAssociationMapper, GoodsCommonAttributeAssociationEntity>
    implements GoodsCommonAttributeAssociationService {


    @Override
    public ResponseResult selectAttribute(Map<String, Object> map) {
        Integer attriId = (Integer) map.get("attriId");
        if (null != attriId) {
            List<GoodsCommonAttributeAssociationEntity> attrAssParams = this.baseMapper.selectList(new LambdaQueryWrapper<GoodsCommonAttributeAssociationEntity>()
                    .eq(GoodsCommonAttributeAssociationEntity::getAttributeId, attriId));
            if (attrAssParams.size() > 0) {
                return ResponseResult.fail(BizCodeEnume.PRODUCT_ATTRIBUTE_HAS_BEEN_PUBLISHED);
            }

        }
        return ResponseResult.success();
    }
}




